import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-09-22
 * Time: 8:12
 */

//P115第一题循环相加
public class CyclicAddition {
    public static void caculate (int a, int m) {
        int i = 1;
        long sum = 0;
        long j = 0;
        int k = a;
        while (i <= m) {
            j = j + k;
            k = (int) (k * Math.pow(10, String.valueOf(a).length()));
            sum = sum + j;
            ++i;
        }
        System.out.println("计算后的值是：" + sum);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入a的值：");
        int a = sc.nextInt();
        //a的值类似于题目中的2，如2+22+222中的2。
        System.out.println("请输入m的值：");
        int m = sc.nextInt();
        //m的值是多少个数相加，如m=2，那么就是2+22。
        caculate(a, m);
    }
}
